package net.huashitong.supervision.gongjian.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.supervision.gongjian.entity.project.ZaijianTisuEntity;
import net.huashitong.supervision.gongjian.filter.ZaijianTisuFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ZaijianTisuDao extends StringDao<ZaijianTisuEntity> {


    public List<ZaijianTisuEntity> getList(ZaijianTisuFilter filter)
    {
        GenericQuery query = createQuery("obj");
        return query.listResult(filter);
    }

    public List<ZaijianTisuEntity> getListNoPage(ZaijianTisuFilter filter)
    {
        GenericQuery query = createQuery("obj");
        return query.listResult();
    }


    public List<ZaijianTisuEntity> getListForOwn(ZaijianTisuFilter filter)
    {
//        GenericQuery query = createQuery("obj");
        String hql = "select z " +
                "     from  ZaijianTisuEntity as z ,GjDeptProject as g " +
                "      where z.sysId=g.projectId ";
        GenericQuery query =create(hql);
        if(StringUtils.isNotBlank(filter.getDeptId()))
        {
            query.append(" and g.deptId=:deptId").setParam("deptId",filter.getDeptId());
        }
        query.append(" and g.projectType=:projectType").setParam("projectType",filter.getProjectType());
        return query.listResult(filter);
    }


}
